<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="${staticServer}/inc/style/main.css" />
<link rel="stylesheet" href="${staticServer}/inc/style/page.css" />
<link rel="stylesheet" href="${staticServer}/inc/style/date/datepicker.css" />
<link rel="stylesheet" href="${staticServer}/css/struct_info.css" />
<link rel="stylesheet" href="${staticServer}/css/consultant_client.css" />
<script src="${staticServer}/inc/js/jquery.js"></script>
<script src="${staticServer}/inc/js/pageset.js"></script>
<script src="${staticServer}/inc/js/datepicker.js"></script>
<script src="${staticServer}/inc/js/infopad.js?2.2"></script>
<script src="${staticServer}/inc/js/city.js"></script>
<script src="${staticServer}/inc/js/htmlfilter.js"></script>
<script src="${staticServer}/inc/js/model_resp.js"></script>
<script src="${staticServer}/inc/js/submitter.js"></script>
<script src="${staticServer}/inc/js/consultants/consultant_client_quest.js?1.4"></script>
<script src="${staticServer}/js/web/consultant_client_state.js?1.2"></script>
<script src="${staticServer}/js/web/consultant_student_func.js?1.0"></script>
<script src="${staticServer}/js/web/consultant_client_first.js?2.1"></script>
<script src="${staticServer}/js/web/consultant_client_check.js?1.1"></script>
<script>
$(function(){
	init_city( "province", "city" );
	
	$("#source").val("<#if clientImp??>${clientImp.source}</#if>");
	$("#tui_username").val("<#if clientImp??>${vote.tui_username}</#if>");
	$("#province").val("<#if clientImp??>${clientImp.province}</#if>");
	$("#city").html("<#if clientImp??><option>${clientImp.city}</option></#if>");
	
	var tui_username = "<#if clientImp??>${clientImp.tui_username}</#if>";
	if(tui_username==""){
		$("#tui_username").val("${webutil.getCookieUser().username}");
	}
	
	var tuiguan = "${webutil.getCookieUser().departments}";
	if(tuiguan=="市场部"){
		$("#source").val("ct5yq4jhc6c7");
	}
	
	$("#souchange").keyup(function(){
		var name = $("#souchange").val();
		if(name==""){
			$("#souchange").val("");
			return;
		}
		$.post("${contextPath}/consu/getSourceByname.json", {
			"name" : name
		}, function(ms) {
			 if(ms.source1!=null){
			 	var sour = ms.source1;
		 		var keyname = sour.keyname;
		 		$("#source").val(keyname);
			 }
		});
	});
})
function getPic(){
    window.open($('#allUrl')[0].src);
}
	var contextPath='${contextPath}';
	
	var insertClient = function(){
		var id = $("#clientImpId").val();
		var lianxi_name = $("#lianxi_name").val();
		var tui_username = $("#tui_username").val();
		var source = $("#source").val();
		var fwly = $("#fwly").val();
		var cs_url = $("#cs_url").val();
		var keyword = $("#keyword").val();
		var province = $("#province").val();
		var city = $("#city").val();
		var address = $("#address").val();
		var phone = $("#phone").val();
		var weixin = $("#weixin").val();
		var qq = $("#qq").val();
		var age = $("#age").val();
		var studentMsg = $("#studentMsg").html();
		var descs = $("#desc").html();
		var jl_time = $("#jl_time").val();
		var keyname = $("#keyname").val();
		
		if(lianxi_name==""){
			alert("客户姓名/称呼不能为空!");
			return;
		}
		if(source==""){
			alert("客户来源渠道不能为空!");
			return;
		}
		if(tui_username==""){
			alert("推广人不能为空!");
			return;
		}
		if(province=="" || city==""){
			alert("所在地不能为空!");
			return;
		}
		if(studentMsg==""){
			alert("孩子情况不能为空!");
			return;
		}
		if(phone=="" && weixin=="" && qq==""){
			alert("联系方式不能为空!");
			return;
		}
		if(jl_time==""){
			alert("获取资源日期不能为空!");
			return;
		}
		$.post("${contextPath}/consu/consultant_importClient_add_go.json",{
			"id" : id,
			"lianxi_name" : lianxi_name,
			"tui_username" : tui_username,
			"type" : source,
			"fwly" : fwly,
			"cs_url" : cs_url,
			"keyword" : keyword,
			"province" : province,
			"city" : city,
			"address" : address,
			"phone" : phone,
			"weixin" : weixin,
			"qq" : qq,
			"age" : age,
			"studentMsg" : studentMsg,
			"descs" : descs,
			"source" : source,
			"keyname" : keyname,
			"jl_time" : jl_time
		},
		function(ms) {
			var msg=ms.msg;
			if(msg=="1"){
				alert("添加成功！");
				setTimeout(function(){
					window.location.href = "${contextPath}/admin/ask_answer_list_market.htm";
				},1000);
			}else{
				alert("添加失败！");
			}
		});
	}


</script>
<style type="text/css">
#statelist label {
	display: block;
	float: left;
	width: 120px;
}
</style>
</head>

<body>
<input type="hidden" value="<#if clientImp??>${clientImp.id}</#if>" id="clientImpId" />
<input type="hidden" value="<#if clientImp??>${clientImp.keyname}</#if>" id="keyname" />
	<div id="home_link">
		<ul>
			<li>竞思教育网络办公系统 v2.0 beta</li>
			<li>&gt;</li>
			<li>资源汇总</li>
			<li>&gt;</li>
			<li class="current">客户资源添加</li>
		</ul>
	</div>
	<div id="container">
		<div id="title"></div>
		<table id="infotable">
			<tr class="fields">
				<th colspan="2">客户基本资料<a id="btn_detailed"></a></th>
			</tr>
			<tr>
				<th width="25%">客户姓名/称呼*
					<p class="caption">若不填写将显示为“匿名”</p>
				</th>
				<td width="75%"><input id="lianxi_name" value="<#if clientImp??>${clientImp.nickname}</#if>" /></td>
			</tr>
			<tr>
				<th>客户来源渠道*</th>
				<td>
                <select id="source">
                	<option value="">-- 请选择 --</option>
                	<#if souList??>
                		<#list souList as list>
                			<option value="${list.keyname}">${list.name}</option>
                		</#list>
                	</#if>
                </select>
                <input type="text" id="souchange" placeholder="输入来源快捷匹配">
				<p class="caption">“百度搜索”是收费竞价排名来源，“百度自然搜索”是免费的关键词搜索来源</p>
					<p class="caption">“商务通其它”是其它推广来源，请在下方“商务通网址”栏填写具体网址（必须）</p></td>
			</tr>
			
			<tr>
				<th>推广人*</th>
				<td>
                <select id="tui_username">
						<option value="">-- 请选择目标 --</option>
						<#if uList??>
							<#list uList as list>
								<option value="${list.username}">${list.nickname}（${list.regions}-${list.departments}-${list.job}）</option>
							</#list>
						</#if>
				</select>
				</td>
			</tr>
			
			<tr>
				<th>访问来源</th>
				<td><input id="fwly" size="50" value="<#if vote??>${vote.fwly}</#if>" maxlength="100" />
					<p class="caption">很重要，商务通中来源为具体网址的必须填写</p></td>
			</tr>
			
			<tr>
				<th>初始访问地址</th>
				<td><input id="cs_url" size="50" maxlength="100" value="<#if vote??>${vote.cs_url}</#if>" />
					<p class="caption">很重要，商务通中来源为具体网址的必须填写</p></td>
			</tr>
			
			<tr>
				<th>关键词</th>
				<td><input id="keyword" size="50" maxlength="100" value="<#if vote??>${vote.keyword}</#if>" />
					<p class="caption">很重要，商务通中来源为具体网址的必须填写</p></td>
			</tr>
			
			<tr>
				<th>所在地*</th>
				<td>
				<select id="province"></select> <em class="caption">（省份）</em> 
				<select id="city"></select> <em class="caption">（城市）</em>
				<p class="caption">当地有中心的客户资源一定要正确选择省和市，这将直接影响业绩统计</p></td>
			</tr>
			<tr>
				<th>具体地址（选填）
					<p class="caption">省市部分省略后的更详细地址</p>
				</th>
				<td><input id="address" size="50" value="<#if clientImp??>${clientImp.address}</#if>" /></td>
			</tr>
			<tr>
				<th>联系电话
					<p class="caption">可以填写手机号码、座机号码</p>
				</th>
				<td>
				<p rel="QUEST_PHONE">
					<input id="phone" name="phone" size="50" maxlength="100" value="<#if clientImp??>${clientImp.phone}</#if>" />
				</p>
				</td>
			</tr>
			<tr>
				<th>微信号</th>
				<td><input id="weixin" size="50" value="<#if clientImp??>${clientImp.weixin}</#if>" />
				<p rel="errnote" style="color: #f30;"></p></td>
			</tr>
			<tr>
				<th>QQ</th>
				<td><input id="qq" value="<#if clientImp??>${clientImp.qq}</#if>" />
				<p rel="errnote" style="color: #f30;"></p></td>
			</tr>
			
			<tr>
				<th>年龄</th>
				<td><input id="age" size="50" maxlength="100" value="<#if vote??>${vote.age}</#if>" /></td>
			</tr>
			
			<tr>
				<th>孩子情况*</th>
				<td><div id="studentMsg" contenteditable="true"><#if vote??>${vote.student_msg}</#if></div>
					<p class="line"></p>
					<p class="caption">学员特征和其它资料</p></td>
			</tr>
			
			<tr>
				<th>备注信息</th>
				<td><div id="desc" contenteditable="true"><#if clientImp??>${clientImp.descs}</#if></div>
					<p class="line"></p>
					<p class="caption">仅供后台标记、备注相关信息使用（会在查询列表中显示该备注）</p></td>
			</tr>
			
			<#if clientImp?? && clientImp.id??>
			<tr>
				<th>获取资源日期*</th>
				<td><div contenteditable="true"><input type="text" placeholder="日期格式如：2017-01-22 13:00:35" id="jl_time" value="<#if vote?? && vote.jl_time?? && vote.jl_time!="">${vote.jl_time?string("yyyy-MM-dd HH:mm:ss")}</#if>" size="35" maxlength="30"></div>
					<p class="line"></p>
					<p class="caption">记录获取本条客户资源的日期。</p></td>
			</tr>
			<#else>
			<tr>
				<th>获取资源日期*</th>
				<td><div contenteditable="true"><input type="text" id="jl_time" size="20" maxlength="20" rel="DATE::Y-m-d" readonly="readonly" class="DatePicker_Icon"></div>
					<p class="line"></p>
					<p class="caption">记录获取本条客户资源的日期。</p></td>
			</tr>	
			</#if>
		</table>
		<div class="remark">
			<ul>
				<li><span class="title">注意事项：</span></li>
				<li>1、咨询过程中可选填客户详细资料，但“客户姓名”务必填写，否则将显示“匿名”</li>
				<li>2、新客户至少需要“电话、QQ、邮箱”中一项联系方式，否则这是无效资源</li>
				<li>3、联系电话最好以手机为准，可以保持更高的准确性、可靠性</li>
			</ul>
		</div>
		<div id="controlbar">
		<#if type=="1">
			<input onclick="insertClient()" type="button" class="submit" value="保存客户咨询记录  " /> 
		</#if>
			<input href="#" onclick="javascript:history.back();" type="button" class="submit" value="返回列表  " /> 
		</div>
	</div>
</body>
</html>